# 登录接口调用
import requests

from common.DBUtil import DBUtil

url_login = "http://ihrm-test.itheima.net/api/sys/login"
headers = {"Content-Type": "application/json"}
body = {"mobile": "13800000002", "password": "123456"}

resp = requests.post(url_login, headers=headers, json=body)
print(resp.json())

token = "Bearer " + resp.json().get("data")
print(token)
# 员工管理-新增员工（令牌） employee
sql = "delete from bs_user where mobile='18210222001';"
DBUtil.uid_db(sql)

url_add_emp = "http://ihrm-test.itheima.net/api/sys/user"
headers = {
    "Content-Type": "application/json",
    "Authorization": token
}
body_add = {"username": "YG","mobile": "18210222001","workNumber": "123"}

resp_add = requests.post(url_add_emp, headers=headers, json=body_add)
print(resp_add.json())